package com.ruoyi.web.controller.qsng;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.qsng.domain.KIntegralDetailed;
import com.ruoyi.qsng.service.IKIntegralDetailedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 积分明细Controller
 *
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/detailed")
@Api(tags = "pc--积分明细Controller")
public class KIntegralDetailedController extends BaseController {
    @Autowired
    private IKIntegralDetailedService kIntegralDetailedService;

    /**
     * 查询积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询积分明细列表")
    public TableDataInfo list(KIntegralDetailed kIntegralDetailed) {
        startPage();
        List<KIntegralDetailed> list = kIntegralDetailedService.selectKIntegralDetailedList(kIntegralDetailed);
        return getDataTable(list);
    }

    /**
     * 导出积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:export')")
    @Log(title = "积分明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出积分明细列表")
    public void export(HttpServletResponse response, KIntegralDetailed kIntegralDetailed) {
        List<KIntegralDetailed> list = kIntegralDetailedService.selectKIntegralDetailedListExport(kIntegralDetailed);
        ExcelUtil<KIntegralDetailed> util = new ExcelUtil<KIntegralDetailed>(KIntegralDetailed.class);
        util.exportExcel(response, list, "积分明细数据");
    }

    /**
     * 获取积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取积分明细详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(kIntegralDetailedService.selectKIntegralDetailedById(id));
    }

    /**
     * 新增积分明细
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:add')")
    @Log(title = "积分明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增积分明细")
    public AjaxResult add(@RequestBody KIntegralDetailed kIntegralDetailed) {
        return toAjax(kIntegralDetailedService.insertKIntegralDetailed(kIntegralDetailed));
    }

    /**
     * 修改积分明细
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:edit')")
    @Log(title = "积分明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改积分明细")
    public AjaxResult edit(@RequestBody KIntegralDetailed kIntegralDetailed) {
        return toAjax(kIntegralDetailedService.updateKIntegralDetailed(kIntegralDetailed));
    }

    /**
     * 删除积分明细
     */
    @PreAuthorize("@ss.hasPermi('qsng:detailed:remove')")
    @Log(title = "积分明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除积分明细")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(kIntegralDetailedService.deleteKIntegralDetailedByIds(ids));
    }
}
